function serialize(object){
    var ret = '';
    for(var n in object){
        ret+= '&'+n+'='+object[n];
    }
    return ret.substr(1);
}
function unSerialize(str){
    var ret = '{';
        ret+= str.replace(/([0-9a-zA-Z\-_]+)=([0-9a-zA-Z\-_\u4E00-\u9FA5]+)/g,'"$1":"$2"').replace(/&/g,',');
        
    ret+='}';
    return JSON.parse(ret);
}
+function($){
	$.ajaxSetup({
	    error:function(x,e){
	        alert("请求出错");
	        return false;
	    }
	});
	
	$.fn.serializeObject=function(multipleToStr){
		multipleToStr=multipleToStr || false;
		var o={};
		var a=this.serializeArray();
		$.each(a,function(){
			if(o[this.name] || o[this.name]==''){
				if(multipleToStr){
					o[this.name]=o[this.name]+','+this.value.trim();
				}else{
					if(!o[this.name].push){
						o[this.name]=[o[this.name]];
					}
					o[this.name].push(this.value.trim() || '');
				}
			}else{
				o[this.name]=this.value.trim() || '';
			}
		});
		return o;
	}
	
	Date.prototype.format = function(format) { //时间戳转换
       var date = {
              "M+": this.getMonth() + 1,
              "d+": this.getDate(),
              "h+": this.getHours(),
              "m+": this.getMinutes(),
              "s+": this.getSeconds(),
              "q+": Math.floor((this.getMonth() + 3) / 3),
              "S+": this.getMilliseconds()
       };
       if (/(y+)/i.test(format)) {
              format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
       }
       for (var k in date) {
              if (new RegExp("(" + k + ")").test(format)) {
                     format = format.replace(RegExp.$1, RegExp.$1.length == 1
                            ? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
              }
       }
       return format;
	}
	
	$.isMobileNum = function(mobile){
		if(!mobile) return false;
		if(!(mobile+'').match(/^(0|86|17951)?(13[0-9]|15[012356789]|17[13678]|18[0-9]|14[57])[0-9]{8}$/)){
    		return false;
    	}
		return true;
	}
	$.isTelNum = function(tel){
		if(!tel) return false;
		if(!(tel+'').match(/^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/)){
    		return false;
    	}
		return true;
	}
}(jQuery);
